package nz.jdbcwrapper;

import java.sql.SQLException;
import java.sql.Statement;
import java.sql.SQLWarning;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.Array;

import java.io.InputStream;

import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Calendar;

class WrapperResultSet extends WarningHolder implements ResultSet
{
  private final ResultSet resultSet;
  private final WrapperStatement statement;
  final Statistic statistic;
  final Data data;
  private boolean closed = false;
  
  private static final Class<ResultSet> oracleResultSet;
  private static final Constructor<WrapperResultSet> wrapperOracleResultSet;

  static {
    Class<ResultSet> callable;
    Constructor<WrapperResultSet> constructor;
    
      try
      {
        callable = (Class<ResultSet>)Class.forName("oracle.jdbc.OracleResultSet");
        Class<WrapperResultSet> wrapperClass = (Class<WrapperResultSet>)Class.forName(WrapperResultSet.class.getPackage().getName() + ".WrapperOracleResultSet");
        constructor = wrapperClass.getConstructor(new Class[] {
                Data.class, 
                WrapperStatement.class, 
                Statistic.class,
                String.class,
                callable});
      }
      catch (Throwable e)
      {
        callable = null;
        constructor = null;
      }
      oracleResultSet = callable;
      wrapperOracleResultSet = constructor;
  }
  
  static WrapperResultSet build(Data data,
                   WrapperStatement statement,
                   Statistic statistic,
                   String parentPrefix,
                   ResultSet resultSet) throws WrapperException {
      if (wrapperOracleResultSet != null && oracleResultSet.isInstance(resultSet)) {
          try {
              return wrapperOracleResultSet.newInstance(new Object[]{data, statement, statistic, parentPrefix, resultSet});
          }
          catch (Exception e) {
              throw new WrapperException(e.toString());
          }
      }
      return new WrapperResultSet(data, statement, statistic, parentPrefix, resultSet);
  }

  WrapperResultSet(Data data,
                   WrapperStatement statement,
                   Statistic statistic,
                   String parentPrefix,
                   ResultSet resultSet) throws WrapperException
  {
    super(parentPrefix);
    this.data = data;
    this.statement = statement;
    this.statistic = statistic;
    this.resultSet = resultSet;
    if (resultSet == null)
      throw new WrapperException(prefix + " Null ResultSet passed to WrapperResultSet");
    
  }

  public boolean next() throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " next()");

    long duration = Long.MIN_VALUE;
    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      boolean next = resultSet.next();
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(next));

      return next;
    }
    catch (SQLException e)
    {
      duration = System.currentTimeMillis() - start;
      if (data.trace >= 5)
        Util.traceEnd(key, e);

      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.fetch(duration);
      checkWarnings();
    }

    throw excp;
  }

  public void close() throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " close()");

    try
    {
      closed = true;
      resultSet.close();

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);

      throw e;
    }
    catch (RuntimeException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);

      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean wasNull() throws SQLException
  {
    long key = 0L;

    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " wasNull()");

    try
    {
      boolean wasNull = resultSet.wasNull();

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(wasNull));

      return wasNull;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);

      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public String getString(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getString(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      String result = resultSet.getString(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public boolean getBoolean(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBoolean(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      boolean result = resultSet.getBoolean(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public byte getByte(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getByte(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      byte result = resultSet.getByte(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public short getShort(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getShort(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      short result = resultSet.getShort(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public int getInt(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getInt(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      int result = resultSet.getInt(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public long getLong(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getLong(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      long result = resultSet.getLong(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public float getFloat(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getFloat(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      float result = resultSet.getFloat(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public double getDouble(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDouble(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      double result = resultSet.getDouble(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBigDecimal(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      BigDecimal result = resultSet.getBigDecimal(columnIndex, scale);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public byte[] getBytes(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBytes(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      byte[] result = resultSet.getBytes(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Date getDate(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDate(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Date result = resultSet.getDate(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Time getTime(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTime(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Time result = resultSet.getTime(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTimestamp(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Timestamp result = resultSet.getTimestamp(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public InputStream getAsciiStream(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getAsciiStream(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      InputStream result = resultSet.getAsciiStream(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public InputStream getUnicodeStream(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getUnicodeStream(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      InputStream result = resultSet.getUnicodeStream(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public InputStream getBinaryStream(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBinaryStream(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      InputStream result = resultSet.getBinaryStream(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public String getString(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getString(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      String result = resultSet.getString(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public boolean getBoolean(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBoolean(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      boolean result = resultSet.getBoolean(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public byte getByte(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getByte(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      byte result = resultSet.getByte(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public short getShort(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getShort(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      short result = resultSet.getShort(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public int getInt(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getInt(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      int result = resultSet.getInt(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public long getLong(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getLong(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      long result = resultSet.getLong(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public float getFloat(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getFloat(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      float result = resultSet.getFloat(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public double getDouble(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDouble(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      double result = resultSet.getDouble(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBigDecimal(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      BigDecimal result = resultSet.getBigDecimal(columnName, scale);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public byte[] getBytes(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBytes(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      byte[] result = resultSet.getBytes(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Date getDate(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDate(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Date result = resultSet.getDate(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Time getTime(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTime(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Time result = resultSet.getTime(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Timestamp getTimestamp(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTimestamp(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Timestamp result = resultSet.getTimestamp(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.io.InputStream getAsciiStream(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getAsciiStream(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.io.InputStream result = resultSet.getAsciiStream(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.io.InputStream getUnicodeStream(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getUnicodeStream(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.io.InputStream result = resultSet.getUnicodeStream(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.io.InputStream getBinaryStream(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBinaryStream(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.io.InputStream result = resultSet.getBinaryStream(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public SQLWarning getWarnings() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getWarnings()");
    try
    {
      SQLWarning warning = resultSet.getWarnings();
      if (data.trace >= 5)
        Util.traceEnd(key, Util.toString(warning));
      return warning;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void clearWarnings() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " clearWarnings()");
    try
    {
      resultSet.clearWarnings();
      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
      warnings.clear();
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public String getCursorName() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getCursorName()");
    try
    {
      String result = resultSet.getCursorName();
      if (data.trace >= 5)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public ResultSetMetaData getMetaData() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 3)
      key = Util.traceBegin(prefix + " getMetaData()");
    try
    {
      WrapperResultSetMetaData result = new WrapperResultSetMetaData(
        data, prefix, resultSet.getMetaData());

      if (data.trace >= 3)
        Util.traceEnd(key, result.prefix);
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 3)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public Object getObject(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getObject(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Object result = resultSet.getObject(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Object getObject(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getObject(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Object result = resultSet.getObject(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public int findColumn(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " findColumn(" + columnName + ")");
    try
    {
      int result = resultSet.findColumn(columnName);
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public java.io.Reader getCharacterStream(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getCharacterStream(" + columnIndex + ")");
    try
    {
      java.io.Reader result = resultSet.getCharacterStream(columnIndex);
      if (data.trace >= 5)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public java.io.Reader getCharacterStream(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getCharacterStream(" + columnName + ")");
    try
    {
      java.io.Reader result = resultSet.getCharacterStream(columnName);
      if (data.trace >= 5)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public BigDecimal getBigDecimal(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBigDecimal(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      BigDecimal result = resultSet.getBigDecimal(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public BigDecimal getBigDecimal(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBigDecimal(" + columnName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      BigDecimal result = resultSet.getBigDecimal(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public boolean isBeforeFirst() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " isBeforeFirst()");
    try
    {
      boolean result = resultSet.isBeforeFirst();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean isAfterLast() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " isAfterLast()");
    try
    {
      boolean result = resultSet.isAfterLast();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean isFirst() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " isFirst()");
    try
    {
      boolean result = resultSet.isFirst();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean isLast() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " isLast()");
    try
    {
      boolean result = resultSet.isLast();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void beforeFirst() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " beforeFirst()");
    try
    {
      resultSet.beforeFirst();
      if (data.trace >= 5)
        Util.traceEnd(key, (String) null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void afterLast() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " afterLast()");
    try
    {
      resultSet.afterLast();
      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean first() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " first()");
    try
    {
      boolean result = resultSet.first();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean last() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " last()");
    try
    {
      boolean result = resultSet.last();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public int getRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getRow()");
    try
    {
      int result = resultSet.getRow();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean absolute(int row ) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " absolute(" + row + ")");
    try
    {
      boolean result = resultSet.absolute(row);
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean relative(int rows ) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " relative(" + rows + ")");
    try
    {
      boolean result = resultSet.relative(rows);
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean previous() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " previous()");
    try
    {
      boolean result = resultSet.previous();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void setFetchDirection(int direction) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " setFetchDirection(" + direction + ")");
    try
    {
      resultSet.setFetchDirection(direction);
      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public int getFetchDirection() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getFetchDirection()");
    try
    {
      int result = resultSet.getFetchDirection();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void setFetchSize(int rows) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " setFetchSize(" + rows + ")");
    try
    {
      resultSet.setFetchSize(rows);
      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public int getFetchSize() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getFetchSize()");
    try
    {
      int result = resultSet.getFetchSize();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public int getType() throws SQLException
  {
    long key = 0L;
    
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + "getType()");
    try
    {
      int result = resultSet.getType();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (Throwable e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      
      if (e instanceof SQLException)
      {
        throw (SQLException) e;
      }
      if (e instanceof RuntimeException)
      {
        throw (RuntimeException)e;
      }
      if (e instanceof Error)
      {
        throw (Error)e;
      }
      throw new RuntimeException(e);
    }
    finally
    {
      checkWarnings();
    }
  }

  public int getConcurrency() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " getConcurrency()");
    try
    {
      int result = resultSet.getConcurrency();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean rowUpdated() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " rowUpdated()");
    try
    {
      boolean result = resultSet.rowUpdated();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean rowInserted() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " rowInserted()");
    try
    {
      boolean result = resultSet.rowInserted();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public boolean rowDeleted() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " rowDeleted()");
    try
    {
      boolean result = resultSet.rowDeleted();
      if (data.trace >= 5)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateNull(int columnIndex) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateNull(" + columnIndex + ")");
    try
    {
      resultSet.updateNull(columnIndex);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBoolean(int columnIndex, boolean x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBoolean()");
    try
    {
      resultSet.updateBoolean(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateByte(int columnIndex, byte x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateByte()");
    try
    {
      resultSet.updateByte(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateShort(int columnIndex, short x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateShort()");
    try
    {
      resultSet.updateShort(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateInt(int columnIndex, int x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateInt()");
    try
    {
      resultSet.updateInt(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateLong(int columnIndex, long x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateLong()");
    try
    {
      resultSet.updateLong(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateFloat(int columnIndex, float x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateFloat()");
    try
    {
      resultSet.updateFloat(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateDouble(int columnIndex, double x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateDouble()");
    try
    {
      resultSet.updateDouble(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBigDecimal()");
    try
    {
      resultSet.updateBigDecimal(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateString(int columnIndex, String x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateString()");
    try
    {
      resultSet.updateString(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBytes(int columnIndex, byte x[]) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBytes()");
    try
    {
      resultSet.updateBytes(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateDate(int columnIndex, java.sql.Date x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateDate()");
    try
    {
      resultSet.updateDate(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateTime(int columnIndex, java.sql.Time x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateTime()");
    try
    {
      resultSet.updateTime(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateTimestamp()");
    try
    {
      resultSet.updateTimestamp(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateAsciiStream(int columnIndex,
                                java.io.InputStream x,
                                int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateAsciiStream()");
    try
    {
      resultSet.updateAsciiStream(columnIndex, x, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBinaryStream(int columnIndex,
                                 java.io.InputStream x,
                                 int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBinaryStream()");
    try
    {
      resultSet.updateBinaryStream(columnIndex, x, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateCharacterStream(int columnIndex,
                                    java.io.Reader x,
                                    int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateCharacterStream()");
    try
    {
      resultSet.updateCharacterStream(columnIndex, x, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateObject(int columnIndex, Object x, int scale) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateObject()");
    try
    {
      resultSet.updateObject(columnIndex, x, scale);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateObject(int columnIndex, Object x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateObject()");
    try
    {
      resultSet.updateObject(columnIndex, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateNull(String columnName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateNull(" + columnName + ")");
    try
    {
      resultSet.updateNull(columnName);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBoolean(String columnName, boolean x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBoolean()");
    try
    {
      resultSet.updateBoolean(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateByte(String columnName, byte x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateByte()");
    try
    {
      resultSet.updateByte(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateShort(String columnName, short x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateShort()");
    try
    {
      resultSet.updateShort(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateInt(String columnName, int x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateInt()");
    try
    {
      resultSet.updateInt(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateLong(String columnName, long x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateLong()");
    try
    {
      resultSet.updateLong(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateFloat(String columnName, float x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateFloat()");
    try
    {
      resultSet.updateFloat(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateDouble(String columnName, double x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateDouble()");
    try
    {
      resultSet.updateDouble(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBigDecimal()");
    try
    {
      resultSet.updateBigDecimal(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateString(String columnName, String x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateString()");
    try
    {
      resultSet.updateString(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBytes(String columnName, byte x[]) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBytes()");
    try
    {
      resultSet.updateBytes(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateDate(String columnName, java.sql.Date x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateDate()");
    try
    {
      resultSet.updateDate(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateTime(String columnName, java.sql.Time x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateTime()");
    try
    {
      resultSet.updateTime(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateTimestamp(String columnName, java.sql.Timestamp x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateTimestamp()");
    try
    {
      resultSet.updateTimestamp(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateAsciiStream(String columnName,
                                java.io.InputStream x,
                                int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateAsciiStream()");
    try
    {
      resultSet.updateAsciiStream(columnName, x, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateBinaryStream(String columnName,
                                 java.io.InputStream x,
                                 int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateBinaryStream()");
    try
    {
      resultSet.updateBinaryStream(columnName, x, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateCharacterStream(String columnName,
                                    java.io.Reader reader,
                                    int length) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateCharacterStream()");
    try
    {
      resultSet.updateCharacterStream(columnName, reader, length);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateObject(String columnName, Object x, int scale) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateObject()");
    try
    {
      resultSet.updateObject(columnName, x, scale);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateObject(String columnName, Object x) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateObject()");
    try
    {
      resultSet.updateObject(columnName, x);
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void insertRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " insertRow()");
    try
    {
      resultSet.insertRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void updateRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " updateRow()");
    try
    {
      resultSet.updateRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void deleteRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " deleteRow()");
    try
    {
      resultSet.deleteRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void refreshRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " refreshRow()");
    try
    {
      resultSet.refreshRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void cancelRowUpdates() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " cancelRowUpdates()");
    try
    {
      resultSet.cancelRowUpdates();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void moveToInsertRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " moveToInsertRow()");
    try
    {
      resultSet.moveToInsertRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public void moveToCurrentRow() throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " moveToCurrentRow()");
    try
    {
      resultSet.moveToCurrentRow();
      if (data.trace >= 6)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  public Statement getStatement() throws SQLException
  {
    if (data.trace >= 5)
      Util.trace(prefix + " getStatement() -> " + statement.prefix);
    return statement;
  }

  public Object getObject(int i, java.util.Map map) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getObject(" + i + ", Map)");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Object result = resultSet.getObject(i, map);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Ref getRef(int i) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getRef(" + i + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Ref result = new WrapperRef(data, statistic, resultSet.getRef(i), prefix);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Blob getBlob(int i) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBlob(" + i + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Blob result = new WrapperBlob(resultSet.getBlob(i));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Clob getClob(int i) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getClob(" + i + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Clob result = new WrapperClob(data, prefix, resultSet.getClob(i));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Array getArray(int i) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getArray(" + i + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Array result = new WrapperArray(data, statistic, prefix, resultSet.getArray(i));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Object getObject(String colName, java.util.Map map) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getObject(" + colName + ", Map)");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Object result = resultSet.getObject(colName, map);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Ref getRef(String colName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getRef(" + colName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Ref result = new WrapperRef(data, statistic, resultSet.getRef(colName), prefix);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Blob getBlob(String colName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getBlob(" + colName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Blob result = new WrapperBlob(resultSet.getBlob(colName));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Clob getClob(String colName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getClob(" + colName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Clob result = new WrapperClob(data, prefix, resultSet.getClob(colName));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public Array getArray(String colName) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getArray(" + colName + ")");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      Array result = new WrapperArray(data, statistic, prefix, resultSet.getArray(colName));
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Date getDate(int columnIndex, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDate(" + columnIndex + ", Calendar))");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Date result = resultSet.getDate(columnIndex, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getDate(" + columnName + ", Calendar))");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Date result = resultSet.getDate(columnName, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Time getTime(int columnIndex, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTime(" + columnIndex + ", Calendar))");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Time result = resultSet.getTime(columnIndex, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTime(" + columnName + ", Calendar))");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Time result = resultSet.getTime(columnName, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTimestamp(" + columnIndex + ", Calendar))");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Timestamp result = resultSet.getTimestamp(columnIndex, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException
  {
    long key = 0L;
    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getTimestamp(" + columnName + ", Calendar)");

    long duration = Long.MIN_VALUE;

    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      java.sql.Timestamp result = resultSet.getTimestamp(columnName, cal);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, String.valueOf(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }
  /**
   * @see java.sql.ResultSet#getURL(int)
   */
  public URL getURL(int columnIndex) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getURL(" + columnIndex + ")");

    long duration = Long.MIN_VALUE;
    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      URL result = resultSet.getURL(columnIndex);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  /**
   * @see java.sql.ResultSet#getURL(String)
   */
  public URL getURL(String columnName) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 6)
      key = Util.traceBegin(prefix + " getURL(" + columnName + ")");

    long duration = Long.MIN_VALUE;
    long start = 0L;
    SQLException excp;

    try
    {
      start = System.currentTimeMillis();
      URL result = resultSet.getURL(columnName);
      duration = System.currentTimeMillis() - start;

      if (data.trace >= 6)
        Util.traceEnd(key, Util.toString(result));
      return result;
    }
    catch (SQLException e)
    {
      if (data.trace >= 6)
        Util.traceEnd(key, e);
      excp = e;
    }
    finally
    {
      if (duration == Long.MIN_VALUE)
        duration = System.currentTimeMillis() - start;
      statistic.column(duration);
      checkWarnings();
    }
    throw excp;
  }

  /**
   * @see java.sql.ResultSet#updateArray(int, Array)
   */
  public void updateArray(int columnIndex, Array x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateArray(" + columnIndex + ", Array)");

    try
    {
      resultSet.updateArray(columnIndex, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateArray(String, Array)
   */
  public void updateArray(String columnName, Array x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateArray(" + columnName + ", Array)");

    try
    {
      resultSet.updateArray(columnName, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateBlob(int, Blob)
   */
  public void updateBlob(int columnIndex, Blob x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateBlob(" + columnIndex + ", Blob)");

    try
    {
      resultSet.updateBlob(columnIndex, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateBlob(String, Blob)
   */
  public void updateBlob(String columnName, Blob x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateBlob(" + columnName + ", Blob)");

    try
    {
      resultSet.updateBlob(columnName, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateClob(int, Clob)
   */
  public void updateClob(int columnIndex, Clob x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateClob(" + columnIndex + ", Clob)");

    try
    {
      resultSet.updateClob(columnIndex, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateClob(String, Clob)
   */
  public void updateClob(String columnName, Clob x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateClob(" + columnName + ", Clob)");

    try
    {
      resultSet.updateClob(columnName, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateRef(int, Ref)
   */
  public void updateRef(int columnIndex, Ref x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateRef(" + columnIndex + ", Ref)");

    try
    {
      resultSet.updateRef(columnIndex, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  /**
   * @see java.sql.ResultSet#updateRef(String, Ref)
   */
  public void updateRef(String columnName, Ref x) throws SQLException
  {
    long key = 0L;

    if (data.trace >= 5)
      key = Util.traceBegin(prefix + " updateRef(" + columnName + ", Ref)");

    try
    {
      resultSet.updateRef(columnName, x);

      if (data.trace >= 5)
        Util.traceEnd(key, (String)null);
    }
    catch (SQLException e)
    {
      if (data.trace >= 5)
        Util.traceEnd(key, e);
      throw e;
    }
    finally
    {
      checkWarnings();
    }
  }

  SQLWarning getProxyWarnings() throws SQLException
  {
    return closed ? null : resultSet.getWarnings();
  }
}
